package com.test.designPattern.creationType.simpleFactoryPattern;

/**
 * 绘画简单工厂
 *
 * @author wangjie
 * @version V1.0
 * @date 2020/4/3
 */
public class ShapeFactory {

    /**
     * 获取形状
     * @param shapeType
     * @return
     */
    public static Shape getShape(String shapeType) {
        if (shapeType == null) {
            return null;
        }
        if (shapeType.equalsIgnoreCase("CIRCLE")) {
            return new Circle();
        } else if (shapeType.equalsIgnoreCase("SQUARE")) {
            return new Square();
        }
        return null;
    }

    public static void main(String[] args) {

        // 获取 Circle 的对象，并调用它的 draw 方法
        Shape circle = ShapeFactory.getShape("CIRCLE");
        circle.draw();
        // 获取 Square 的对象，并调用它的 draw 方法
        Shape square = ShapeFactory.getShape("SQUARE");
        square.draw();
    }
}
